<?php

/**
 * @package Core
 * @author superx
 */
class Core_Validator_LengthBetween implements Core_Validator_Interface {
    public $min = 0;
    public $max = 0;
    public $encoding = 'utf-8';

    public function __construct($min, $max, $encoding = 'utf-8') {
        $this->min = $min;
        $this->max = $max;
        $this->encoding = $encoding;
    }

    public function isValid($data) {
        $length = mb_strlen($data, $this->encoding);
        return (($length >= $this->min) && ($length <= $this->max));
    }
}
